package com.mixsmart.spellsql.where.exp;

import com.mixsmart.spellsql.IExpression;
import com.mixsmart.spellsql.where.CompositeWhere;
import com.mixsmart.utils.StringUtils;

/**
 * 左like　<br />
 * 如：like "%流量"
 * @author lmq
 * @version 1.0
 * @since 1.0
 * 
 */
public class LeftLikeExpression extends CompositeWhere implements IExpression {

	private String fieldName;
	
	private Object value;
	
	public LeftLikeExpression(String fieldName,Object value) {
		this.fieldName = fieldName;
		this.value = value;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public String build() {
		String valueStr = StringUtils.handNull(value);
		if(StringUtils.isNotEmpty(valueStr)) {
			if(!valueStr.startsWith("%")) {
				valueStr = "%"+valueStr;
			}
		}
		super.getParam(fieldName, valueStr);
		return fieldName+" like :"+fieldName+"";
	}

}
